package pack05_covid_sort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author lilulu
 * @date 2023/2/11 13:44
 */
public class CovidSortMapper extends Mapper<LongWritable, Text, CovidSortBean, NullWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        //得到k2,v2,写入上下文中
        String[] split = value.toString().split("\t");
        CovidSortBean covidSortBean = new CovidSortBean();
        covidSortBean.setState(split[0]);
        covidSortBean.setCases(Integer.parseInt(split[1]));
        covidSortBean.setDeaths(Integer.parseInt(split[2]));

        context.write(covidSortBean,NullWritable.get());
    }
}
